package com.shensi.api.admin.client.common;

import com.shensi.api.admin.client.fallback.common.CommonClientFallBack;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.common.core.domain.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: budian
 * @since: 2023/11/30
 */
@FeignClient(
        value = CloudConstant.SHENSI_ADMIN_COLLECT,
        fallbackFactory = CommonClientFallBack.class)
@Component
public interface CommonClient {


    @GetMapping("common/download")
    public void fileDownload(@RequestParam(value = "fileName") String fileName,
                             @RequestParam(value = "delete") Boolean delete,
                             @RequestParam(value = "response") HttpServletResponse response,
                             @RequestParam(value = "request") HttpServletRequest request);

    /**
     * 下载文件去除时间戳前缀
     */
    @GetMapping("common/downloadFile")
    public void fileDownloadExcel(@RequestParam(value = "fileName") String fileName,
                                  @RequestParam(value = "delete") Boolean delete,
                                  @RequestParam(value = "response") HttpServletResponse response,
                                  @RequestParam(value = "request") HttpServletRequest request);

    /**
     * 通用上传请求
     */
    @PostMapping("/common/upload")
    public AjaxResult uploadFile(MultipartFile file) throws Exception;

    /**
     * 支付项目调用上传请求
     */
    @PostMapping("/common/uploadFile")
    public AjaxResult apiPayUploadFile(MultipartFile file) throws Exception;

    /**
     * 通用上传请求
     * TODO
     */
    @PostMapping("/wxUpload")
    public AjaxResult upload(@RequestParam(value = "file") MultipartFile file,@RequestParam(value = "enterpriseId") Long enterpriseId);

    @PostMapping(value = "/test2")
    public void uploadMedia3(@RequestPart("media") MultipartFile media);

    /**
     * 本地资源通用下载
     */
    @GetMapping("/common/download/resource")
    public void resourceDownload(@RequestParam(value = "name") String name,
                                 @RequestParam(value = "request") HttpServletRequest request,
                                 @RequestParam(value = "response") HttpServletResponse response) throws Exception;
}
